<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>穷在闹市出品</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/manager/css/base.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/manager/css/iconfont.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/manager/framework/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/manager/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/manager/layui/layui.js"></script>
    <!-- 滚动条插件 -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/manager/css/jquery.mCustomScrollbar.css">
    <script src="${pageContext.request.contextPath}/manager/framework/jquery-ui-1.10.4.min.js"></script>
    <script src="${pageContext.request.contextPath}/manager/framework/jquery.mousewheel.min.js"></script>
    <script src="${pageContext.request.contextPath}/manager/framework/jquery.mCustomScrollbar.min.js"></script>
    <script src="${pageContext.request.contextPath}/manager/framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->

</head>
<script>

    layui.use('table', function() {
        var table = layui.table;
        $.ajax({
            url:'${pageContext.request.contextPath}/sortServlet?action=getList',
            type:"post",
            dataType:"json",
            success:function (data) {
                // alert(data)
                table.render({
                    elem: '#test'
                    ,toolbar: '#toolbarDemo'
                    ,data:data
                    ,title: '用户数据表'
                    ,cols:
                        [[ //表头
                            {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
                            ,{field: 'typeName', title: '分类名称', width:150}
                            ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:65}
                        ]]
                    ,page: true //是否显示分页
                    ,limits: [10, 20, 30]
                    ,limit: 10 //每页默认显示的数量

                });

            }

        })
        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;

            //console.log(obj)
            if(obj.event === 'del'){
                console.log(data)
                layer.confirm('确定删除这条数据？', function(index){
                    obj.del();
                    layer.close(index);
                    window.location.href="${pageContext.request.contextPath}/flowerServlet?action=deleteFlower&id="+data.id;
                });
            }

        });

    })



</script>

<body>
<div class="cBody">
    <div class="console">
<%--        检索--%>
<%--        <form class="layui-form" action="">--%>
<%--            <div class="layui-form-item">--%>
<%--                <div class="layui-input-inline">--%>
<%--                    <input type="text" name="name" required lay-verify="required" placeholder="输入分管名称" autocomplete="off" class="layui-input">--%>
<%--                </div>--%>
<%--                <button class="layui-btn" lay-submit lay-filter="formDemo">检索</button>--%>
<%--            </div>--%>
<%--        </form>--%>

    <table class="layui-hide" id="test" lay-filter="test">

    </table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>

</body>

</html>
